#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int a = 10;

int main()
{
	int b = 20; //局部变量
	pid_t pid;
	pid = fork();
	if (pid < 0)
	{
		//没有创建成功
		perror("fork");
	}

	if(pid == 0)
	{//子进程
		a = 111;
		b = 222;
		printf("son: a = %d, b = %d\n", a, b);	
	}
	else if(pid > 0)
	{ //父进程
		sleep(1);
		printf("father: a = %d, b = %d\n", a, b);
	}
	return 0;
}
